function returnValue = checkConnectionMetabolitesOrModelIsUsed()

    defines = evalin('base','defines');
    metabolites = '';
    
    if str2num(defines.isProductUsed) & str2num(defines.isSubstrateUsed)
         if ~str2num(defines.useProductConnectionMetabolites) && ~str2num(defines.useSubstrateConnectionMetabolites)
            returnValue = 'model';
            return;
        else
            metabolites = [cellstr(defines.substrateConnectionMetabolites); cellstr(defines.productConnectionMetabolites)];
        end  
    elseif str2num(defines.isProductUsed) & ~str2num(defines.isSubstrateUsed)
        if ~str2num(defines.useProductConnectionMetabolites)
            returnValue = 'model';
            return;
        else
            metabolites = cellstr(defines.productConnectionMetabolites);
        end  
   elseif ~str2num(defines.isProductUsed) & str2num(defines.isSubstrateUsed)
        if ~str2num(defines.useSubstrateConnectionMetabolites)
            returnValue = 'model';
            return;
        else
            metabolites = cellstr(defines.substrateConnectionMetabolites);
        end  
    end
    
    
    
%     if (~str2num(defines.isSubstrateDirection) && ~str2num(defines.useProductConnectionMetabolites)) ...
% %             || (str2num(defines.isSubstrateDirection) && ~str2num(defines.useSubstrateConnectionMetabolites)) ...
% %             || (~str2num(defines.isSubstrateDirection) && ~str2num(defines.useProductConnectionMetabolites))
%         returnValue = 'model';
%        % return;
%     elseif str2num(defines.isSubstrateDirection) && str2num(defines.useSubstrateConnectionMetabolites)
%          metabolites = cellstr(defines.substrateConnectionMetabolites);
%     elseif ~str2num(defines.isSubstrateDirection) && str2num(defines.useProductConnectionMetabolites)
%          metabolites = cellstr(defines.productConnectionMetabolites);
%     end

        
    model = evalin('base', 'model');
    modelMetabolites = unique(model.metKEGGID);
    modelMetabolites = modelMetabolites(~cellfun('isempty',modelMetabolites));  
    clear model;

    metabolitesString = {''};
    boolIsNotInModel = false;
    boolOneOrMoreIsNotInModel = false;
    for i = 1 : length(metabolites)
        for j = 1 : length(modelMetabolites)
            if strcmp(modelMetabolites{j},metabolites{i})
                metabolitesString = [metabolitesString; metabolites{i},' - IS in the model'];
                boolIsNotInModel = true;
            end
        end    

        if ~boolIsNotInModel
            metabolitesString = [metabolitesString; metabolites{i},' - IS NOT in the model' ];
            boolOneOrMoreIsNotInModel = true;

        end
        boolIsNotInModel = false;
    end

    metabolitesString{1} = 'One or many metabolites are not on the model. You can cancel and currate the model manually and add necessary KEGGIDs or continue with existing model?';
    str = char(metabolitesString);

     if boolOneOrMoreIsNotInModel
        choice = questdlg(str, ...
            'Many metabolites are not presented in the model. If you continue,they will be removed from the list','Continue','Cancel','o')

        if strcmp(choice,'Continue')
            mets = metabolites;
            for i = 1 : length(metabolites)
                mets{i} = '';
            end
            mets = mets(~cellfun('isempty',mets));
            assignin('base', 'connectionMetabolites', mets)
            returnValue = 'connectionMetabolites';
        else 
            returnValue = 'cancel';
        end
     else
        returnValue = 'connectionMetabolites';
        assignin('base', 'connectionMetabolites', metabolites)
     end

end